package api

import (
	"encoding/json"
	"io/ioutil"
	"net/http"
	"net/url"
)

type Result struct {
	Code string      `json:"code"`
	Msg  string      `json:"msg"`
	Time int64       `json:"time"`
	Data interface{} `json:"data"`
}

func ApiSearchFile(requestUrl, filekey string) Result {
	params := url.Values{}
	Url, err := url.Parse(requestUrl)
	if err != nil {
		return Result{}
	}
	params.Set("fileKey", filekey)
	Url.RawQuery = params.Encode()
	urlPath := Url.String()
	resp, err := http.Get(urlPath)
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	var vo Result
	_ = json.Unmarshal(body, &vo)
	return vo
}
